<template>
  <view>
    <yy-paging
      v-model="dataList"
      @query="queryList"
      ref="paging"
      :auto="automatic"
      @scroll="scroll"
      :refresher-enabled="false"
    >
      <template #top>
        <u-navbar
          :is-back="false"
          :background="{ backgroundColor: isScroll ? '#F2F5F7' : 'transparent' }"
          :border-bottom="false"
          :custom-style="{ transition: 'background-color 0.3s ease-in-out' }"
        >
          <view class="grid grid-cols-3 items-center px-3 w-full">
            <view class="flex col-span-1 items-center" @click="vk.navigateBack()">
              <image src="/static/dddr128.png" mode="aspectFill" class="size-6" />
            </view>
            <view class="line-clamp-1 flex col-span-1 justify-center">
              <view class="text-[#000] font-bold text-base"> 支付宝账号 </view>
            </view>
            <view class="flex col-span-1 justify-end">
              <view class="text-[14px] text-[#5C6068]"> </view>
            </view>
          </view>
        </u-navbar>
      </template>
      <template #empty>
        <yy-empty></yy-empty>
      </template>
      <template #loadingMoreNoMore>
        <yy-nomore></yy-nomore>
      </template>
      <view class="flex flex-col justify-center items-center p-4">
        <view class="size-[3.5rem] rounded-full mt-16">
          <image src="/static/dddr28.png" class="size-full" mode="aspectFill" />
        </view>
        <view class="text-[1rem] text-[#161A24] font-medium mt-4"> 已绑定支付宝账号</view>
        <view class="text-[.75rem] text-[#161A24] font-medium mt-2">{{ accounts }}</view>
        <view
          class="w-2/3 h-[2.75rem] bg-[#00A9AB] rounded-full flex justify-center items-center btn mt-8"
          @click="unBindAlipay"
        >
          <view class="font-medium text-[1rem] text-[#FFFFFF]"> 解除绑定</view>
        </view>
      </view>
    </yy-paging>
    <yy-alert ref="alert" @alertConfirm="alertConfirm"></yy-alert>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        isScroll: false, // 是否滚动
        dataList: [], // 数据列表
        automatic: false, // 是否自动加载
        accounts: '', // 支付宝账号
        id: '' // 解绑ID
      }
    },
    onLoad(options) {
      this.id = options.id
      this.accounts = options.accounts
    },

    methods: {
      async alertConfirm() {
        let res = await api.unBindWithdrawalAccount({ id: this.id })
        if (!res.code) return vk.toast(res.msg)
        vk.toast(res.msg, 200, e => {
          vk.navigateBack()
        })
      },
      unBindAlipay() {
        this.$refs.alert.config({
          show: true,
          title: '解除绑定提示',
          describe: '解绑后无法收款，请确认是否解绑？',
          cancel: '取消',
          cancelColor: '#000',
          confirm: '确认解绑',
          confirmColor: '#00A9AB',
          eventType: 'unBindAlipay'
        })
      },
      scroll(e) {
        this.isScroll = e.detail.scrollTop > 0
      },
      async queryList(page, limit) {
        this.$refs.paging.complete([1, 1, 1])
      }
    }
  }
</script>

<style lang="scss" scoped></style>
